<template>
    <view class="s-padding">
		<view class="s-product-list">
      		<view class="s-product-container">
      			<block v-for="(item,index) in product_list" :key="index" v-if="(index+1)%2!=0 || isList">
      				<!--商品列表-->
      				<view class="s-pro-item" :class="[isList?'s-flex-list':'']" hover-class="hover" :hover-start-time="150"  @tap="product_detail(item.id)">
      					<image :src="item.image_url" class="s-pro-img" :class="[isList?'s-proimg-list':'']" mode="widthFix" />
      					<view class="s-pro-content">
      						<view class="s-pro-tit">{{item.name}}</view>
      						<view>
      							<view class="s-pro-price">
      								<text class="s-sale-price">￥{{item.money}}</text>
      								<text class="s-factory-price">￥{{item.bazaar_money}}</text>
      							</view>
      							<view class="s-pro-pay">{{item.sales}}人付款</view>
      						</view>
      					</view> 
      				</view>
      			</block>
      		</view>
      		<view class="s-product-container" v-if="!isList">
      			<block v-for="(item,index) in product_list" :key="index" v-if="(index+1)%2==0">
      				<!--商品列表-->
      				<view class="s-pro-item" :class="[isList?'s-flex-list':'']" hover-class="hover" :hover-start-time="150" @tap="product_detail(item.id)">
      					<image :src="item.image_url" class="s-pro-img" :class="[isList?'s-proimg-list':'']" mode="widthFix" />
      					<view class="s-pro-content">
      						<view class="s-pro-tit">{{item.name}}</view>
      						<view>
      							<view class="s-pro-price">
      								<text class="s-sale-price">￥{{item.money}}</text>
      								<text class="s-factory-price">￥{{item.bazaar_money}}</text>
      							</view>
      							<view class="s-pro-pay">{{item.sales}}人付款</view>
      						</view>
      					</view>
      				</view>
      			</block>
      		</view>
      	</view>
    </view>
</template>
<script>
export default {
  name: 'cProductList',
  data () {
    return {
	  product_list:[]
    }
  },
  props: {
	  list: {
	    type: Array,
	    default: function () {
			return []
		}
	  },
	  isList: {
	  	type: Boolean,
	  	default: false
	  }
  },
  watch: {
    list: function (val) { // 监听props中的属性
      this.product_list = val
    }
  },
  methods: {
	  product_detail(id){
		  uni.navigateTo({url: '../../pages/product_detail/product_detail?id='+id})
	  }
  }
}
</script>
<style lang="scss" scoped>
@import 'product-list.scss';
</style>